package cn.yh.register.user.controller;

import cn.yh.register.common.result.Result;
import cn.yh.register.model.user.UserInfo;
import cn.yh.register.user.service.UserInfoservice;
import cn.yh.register.vo.user.UserInfoQueryVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(tags = "用户管理接口")
@RestController
@RequestMapping("/admin/user")
public class UserInfoController {
    @Autowired
    private UserInfoservice userInfoservice;

    //用户列表（条件查询带分页）
    @ApiOperation("用户列表（条件查询带分页）")
    @GetMapping("/{page}/{limit}")
    public Result<Page<UserInfo>> list(@PathVariable("page") Integer current,
                                       @PathVariable Integer limit,
                                       UserInfoQueryVo queryVo) {
        Page<UserInfo> userList = userInfoservice.findUserList(current, limit, queryVo);
        return Result.ok(userList);
    }


    @ApiOperation(value = "锁定")
    @GetMapping("/lock/{userId}/{status}")
    public  Result<?> lock( @PathVariable("userId") Long userId,
                           @PathVariable("status") Integer status){
        userInfoservice.lock(userId, status);
        return Result.ok();
    }

    @ApiOperation("查询用户详情")
    @GetMapping("/show/{userId}")
    public Result<Map<String, Object>> show(@PathVariable Long userId){
        Map<String, Object> map = userInfoservice.show(userId);
        return Result.ok(map);
    }


    @ApiOperation("认证审批")
    @GetMapping("/approval/{userId}/{authStatus}")
    public Result<?> approval(@PathVariable Long userId,@PathVariable Integer authStatus){
        userInfoservice.approval(userId, authStatus);
        return Result.ok();
    }
}
